package com.example.landmanagement.common.exception;


import com.example.landmanagement.util.ReturnBeanSim;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;

/**
 * className GlobalExceptionManager
 *  全局异常处理类
 * @author Java DaKun
 * @date 2021/7/14
 * @version:1.0
 * @since:jdk:1.8
 */
@ControllerAdvice
public class GlobalExceptionManager {

    @ExceptionHandler(Exception.class)
    public ResponseEntity doException(Exception e){
        e.printStackTrace();
        return ResponseEntity.ok(e.getMessage());
    }

    @ExceptionHandler(MVCException.class)
    public ResponseEntity doMVCException(MVCException e){
        System.out.println("MVC异常");
       return ResponseEntity.ok(new ReturnBeanSim(e.getCodeEnum()));
    }


}
